<?php

/**
 * This is the model class for table "tbl_sales_departments_cat".
 *
 * The followings are the available columns in table 'tbl_sales_departments_cat':
 * @property integer $id
 * @property string $description
 * @property string $debit
 * @property string $credit
 * @property string $division
 * @property integer $inactive
 * @property string $sales_department
 * @property string $code
 * @property string $locktime
 * @property string $lockby
 */
class SalesDepartmentsCat extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return SalesDepartmentsCat the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_sales_departments_cat';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('inactive', 'numerical', 'integerOnly'=>true),
			array('description, locktime', 'length', 'max'=>20),
			array('debit, credit', 'length', 'max'=>10),
			array('division', 'length', 'max'=>36),
			array('sales_department', 'length', 'max'=>2),
			array('code', 'length', 'max'=>25),
			array('lockby', 'length', 'max'=>30),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, description, debit, credit, division, inactive, sales_department, code, locktime, lockby', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'description' => 'Description',
			'debit' => 'Debit',
			'credit' => 'Credit',
			'division' => 'Division',
			'inactive' => 'Inactive',
			'sales_department' => 'Sales Department',
			'code' => 'Code',
			'locktime' => 'Locktime',
			'lockby' => 'Lockby',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('description',$this->description,true);
		$criteria->compare('debit',$this->debit,true);
		$criteria->compare('credit',$this->credit,true);
		$criteria->compare('division',$this->division,true);
		$criteria->compare('inactive',$this->inactive);
		$criteria->compare('sales_department',$this->sales_department,true);
		$criteria->compare('code',$this->code,true);
		$criteria->compare('locktime',$this->locktime,true);
		$criteria->compare('lockby',$this->lockby,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}